package com.mmsj;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

    Button startBtn;
    Button stopBtn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        startBtn  = findViewById(R.id.start_service);
        stopBtn  = findViewById(R.id.stop_service);

//        给按钮绑定 点击事件
        startBtn.setOnClickListener(v -> {
            // 启动服务
            Intent intent = new Intent(this, MyService.class);
            //
            Bundle bundle = new Bundle();
            bundle.putString("name", "张三");
            bundle.putInt("age", 18);
            intent.putExtras(bundle);
            startService(intent);
        });
        stopBtn.setOnClickListener(v -> {
            Intent intent = new Intent(this, MyService.class);
            stopService(intent);
        });
    }
}